#include <pthread.h>

class Mutex
{
public:
    Mutex(pthread_mutex_t* lock):_lock(lock)
    {}
    void lock()
    {
        pthread_mutex_lock(_lock);
    }
    void unlock()
    {
        pthread_mutex_unlock(_lock);
    }
    ~Mutex()
    {}

private:
    pthread_mutex_t* _lock;
};

class lockGurad
{
public:
    lockGurad(pthread_mutex_t* mtx):_mtx(mtx)
    {
        _mtx.lock();
    }
    ~lockGurad()
    {
        _mtx.unlock();
    }

private:
    Mutex _mtx;
};